import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import { fileURLToPath, URL } from "node:url";

// https://vitejs.dev/config/
export default ({ mode }) => {
  return defineConfig({
    plugins: [vue()],
    resolve: {
      alias: {
        "@": fileURLToPath(new URL("./src", import.meta.url)),
        vue: "vue/dist/vue.esm-bundler.js",
      },
    },
    server: {
      port: loadEnv(mode, process.cwd()).VITE_PORT,
      host: "0.0.0.0",
      open: true,
      proxy: {
        "/services": {
          target: loadEnv(mode, process.cwd()).VITE_PROXY,
          secure: false,
          changeOrigin: true,
        },
      },
    },
  });
};
